﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
using CuadroMandoIntegralFMCH.Form_s.Login;
using CuadroMandoIntegralFMCH.Form_s.Prestadores;
using CuadroMandoIntegralFMCH.Form_s.Debitos;
using CuadroMandoIntegralFMCH.Form_s.Reclamos;
using DAL;
using DAL.Modelos;

namespace CuadroMandoIntegralFMCH.Form_s
{
    public partial class MenuPrincipal : Form
    {
        private HistorialSesione historial;
        private MenuPrincipal menu;
        private Hash hash = new Hash();

        public MenuPrincipal()
        {
            menu = this;
            InitializeComponent();
            var login = new InicioSesion(menu);
            login.ShowDialog();
        }

        public void Historial(HistorialSesione historialUsuario, Hash h)
        {
            historial = historialUsuario;
            hash = h;
            Permisos();
        }

        public void Permisos()
        {
            if (hash.tipoUsuario == 3)
            {
                importarTiposDebitosToolStripMenuItem.Enabled = false;
                importarToolStripMenuItem2.Enabled = false;
                importarToolStripMenuItem3.Enabled = false;
                totalizarToolStripMenuItem.Enabled = false;
                crearUsuarioToolStripMenuItem.Enabled = false;
                pathToolStripMenuItem.Enabled = false;
                holsToolStripMenuItem.Enabled = false;
            }
            else if (hash.tipoUsuario == 2)
            {
                importarTiposDebitosToolStripMenuItem.Enabled = false;
                importarToolStripMenuItem2.Enabled = false;
                importarToolStripMenuItem3.Enabled = false;
                totalizarToolStripMenuItem.Enabled = false;
                crearUsuarioToolStripMenuItem.Enabled = false;
                pathToolStripMenuItem.Enabled = false;
                holsToolStripMenuItem.Enabled = false;
            }
        }

        private void importarToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            var obraSocialImportar = new ObraSocialImportar();
            obraSocialImportar.Show();
        }

        private void importarToolStripMenuItem2_Click_1(object sender, EventArgs e)
        {
            var prestadorImportar = new PrestadoresImportar();
            prestadorImportar.Show();
        }

        private void importarToolStripMenuItem3_Click_1(object sender, EventArgs e)
        {
            var debitosImportar = new DebitosImportar();
            debitosImportar.Show();
        }

        private void importarTiposDebitosToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            var motivoDebitoImportar = new DebitosImportarTipos();
            motivoDebitoImportar.Show();
        }

        private void consultarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var consultar = new DebitosConsultar();
            consultar.Show();
        }

        private void totalizarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var procesar = new DebitosProcesarTotales();
            procesar.Show();
        }

        private void crearUsuarioToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            var usuariosCrear = new UsuarioCrear();
            usuariosCrear.Show();
        }

        private void MenuPrincipal_FormClosed(object sender, FormClosedEventArgs e)
        {
            var cierre = DateTime.Now;
            historial.Cierre = cierre;
            var mensaje = new Modelo().UpdateHistorialSesiones(historial);

            if (!mensaje.status)
                MessageBox.Show(mensaje.message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

        }

        private void nuevoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var reclamoNuevo = new ReclamosNuevo(hash);
            reclamoNuevo.Show();
        }

        private void pathToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MessageBox.Show(Application.StartupPath);
        }

        private void holsToolStripMenuItem_Click(object sender, EventArgs e)
        {
           MessageBox.Show("Version: " + Application.ProductVersion);
        }

        private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
        {
            var estadistica = new DebitosEstadisticas();
            estadistica.Show();
        }


       

    
    }
}
